package svc

import (
	"github.com/zeromicro/go-zero/core/stores/redis"
	"go-zero-demo/apps/user/cmd/api/internal/config"
	"go-zero-demo/common/utils"
)

type ServiceContext struct {
	Config      config.Config
	Validator   utils.Validator
	RedisClient *redis.Redis
}

func NewServiceContext(c config.Config) *ServiceContext {
	redisConf := redis.RedisConf{Host: c.RedisConf.Host}
	return &ServiceContext{
		Config:      c,
		Validator:   utils.NewZhValidator(),
		RedisClient: redis.MustNewRedis(redisConf),
	}
}
